#include <algorithm>
#include <cstdio>
#include <cstring>
#include <vector>
constexpr int MaxN = 3e3 + 5;
constexpr int MaxM = 1e4 + 5;
class thing
{
  public:
    long long cost;
    long long value;
    thing(long long a = 0, long long b = 0)
    {
        cost = a;
        value = b;
    }
};
int n, m;
int c[MaxN];
int t[MaxN];
int w[MaxN];
long long dp[MaxN][MaxM];
std::vector<thing> v;
int main()
{
    freopen("book.in", "r", stdin);
    freopen("book.out", "w", stdout);
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
    {
        scanf("%d", &c[i]);
    }
    for (int i = 1; i <= n; i++)
    {
        scanf("%d", &t[i]);
    }
    for (int i = 1; i <= n; i++)
    {
        scanf("%d", &w[i]);
    }
    scanf("%d", &m);
    v.push_back({});
    long long max = 0;
    for (int i = 1; i <= n; i++)
    {
        for (int j = 0; j < 32; j++)
        {
            if (c[i] < (1ll << j) || (1ll << j) * t[i] > m)
            {
                break;
            }
            v.push_back({(1ll << j) * t[i], (1ll << j) * w[i]});
            c[i] -= 1 << j;
        }
        if (c[i] != 0 && c[i] * t[i] <= m)
        {
            v.push_back({1ll * c[i] * t[i], 1ll * c[i] * w[i]});
        }
    }
    n = v.size() - 1;
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= m; j++)
        {
            if (j < v[i].cost)
            {
                dp[i][j] = dp[i - 1][j];
            }
            else
            {
                dp[i][j] = std::max(dp[i - 1][j], dp[i - 1][j - v[i].cost] + v[i].value);
            }
        }
    }
    printf("%lld\n", dp[n][m]);
    return 0;
}